<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/jquery.ui.combobox.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/jquery.ui.widget.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/jquery.ui.widget.min.js"></script>

<?php $site_form = $this->beginWidget('CActiveForm', array(
		'id'=>'site-form',
		'enableClientValidation'=>true,
	//	'enableAjaxValidation'=>true,
		));
?>

<?php echo CHtml::hiddenField('profile_site_ID_field', '0'); ?>

<div id="mysite-head-right">Site Profile</div>

<div id="ms-main-contents">

<div align='left' style='color:#FF0000'>
<?php
	echo $site_form->error($site, 'site_name');
	echo $site_form->error($site, 'address1');//address1
	echo $site_form->error($site, 'address2');//address2
	echo $site_form->error($site, 'county');
	echo $site_form->error($site, 'city');
	echo $site_form->error($site, 'state');
	echo $site_form->error($site, 'zip');
	echo $site_form->error($site, 'county');
?>
</div>
<div id="sp-left">
<div id="sp-left-head">site details</div>

<div id="site-details2">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th>Site Name</th>
    <td>
    	<div class="sp-textbox1">
    		<?php echo $site_form->textField($site, 'site_name', array('onchange'=>'changeStatus(DOMAIN.PROFILE, STATUS.CHANGED)')); ?>
    	</div>
    </td>
  </tr>
  <tr>
    <th>Address 1</th>
    <td>
    	<div class="sp-textbox1">
    		<?php echo $site_form->textField($site, 'address1', array('onchange'=>'changeStatus(DOMAIN.PROFILE, STATUS.CHANGED)')); ?>
    	</div>
    </td>
  </tr>
  <tr>
    <th>Address 2</th>
    <td>
    	<div class="sp-textbox1">
    		<?php echo $site_form->textField($site, 'address2', array('onchange'=>'changeStatus(DOMAIN.PROFILE, STATUS.CHANGED)')); ?>
    	</div>
    </td>
  </tr>
  <tr>
    <td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <th>City</th>
        <td width="194">
        	<div class="sp-textbox2">
        		<?php echo $site_form->textField($site, 'city', array('onchange'=>'changeStatus(DOMAIN.PROFILE, STATUS.CHANGED)')); ?>
        	</div>
        </td>
        <td width="28" style="padding-right:4px;">State</td>
        <td>
        	<div class="sp-textbox3"><select id="Sites_state" name="Sites[state]" onchange'=>'changeStatus(DOMAIN.PROFILE, STATUS.CHANGED)>
			  	<?php 
			  	$states = USStates::model()->getAllStates();
			  	foreach ($states as $state) { 
		          	echo '<option >'.$state->abbreviation_name.'</option>';
	          	} 
	          	?>
		  	</select></div>
        </td>
      </tr>
    </table></td>
    </tr>
  <tr>
    <td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <th>Zip code</th>
        <td width="147">
        	<div class="textboxsb6">
        		<?php echo $site_form->textField($site, 'zip', array('onchange'=>'changeStatus(DOMAIN.PROFILE, STATUS.CHANGED)')); ?>
        	</div>
        </td>
        <td width="36">County</td>
        <td>
        	<div class="sp-textbox4">
        		<?php echo $site_form->dropDownList($site, 'county', $site->loadCounties(), array('onchange'=>'changeStatus(DOMAIN.PROFILE, STATUS.CHANGED)')); ?>
        	</div>
        </td>
      </tr>
    </table></td>
    </tr>
  <tr>
    <th>Home rack</th>
    <td>
    	<div class="sp-textbox1">
    		<?php
    		 echo $site_form->dropDownList($site, 'home_rack_ID', Racks::model()->getRacksInfo(), array('style' => 'width:280px', 'onchange'=>'changeStatus(DOMAIN.PROFILE, STATUS.CHANGED)')); 
    		/*	$this->widget('ext.combobox.EJuiComboBox', array(
				    'model' => $site,
				    'attribute' => 'home_rack_ID',
				    // data to populate the select. Must be an array.
				    'data' => Racks::model()->getRacksInfo(),
				    // options passed to plugin
				    'options' => array(
				        // JS code to execute on 'select' event, the selected item is
				        // available through the 'item' variable.
				   //     'onSelect' => 'alert("selected value : " + item.value);',
				        // JS code to be executed on 'change' event, the input is available
				        // through the '$(this)' variable.
				   //     'onChange' => 'alert("changed value : " + $(this).val());',
				        // If false, field value must be present in the select.
				        // Defaults to true.
				        'allowText' => false,
				    ),
				    // Options passed to the text input
				//    'htmlOptions' => array('size' => 10),
				));*/
    		?>
    	</div>
    </td>
  </tr>
  <tr>
    <td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<!--      <tr>
        <th>Lat</th>
        <td width="138"><div class="sp-textbox5">
          <input type="text" /></div></td>
        <td width="30">Long</td>
        <td><div class="sp-textbox5"><input type="text" /></div></td>
      </tr>-->
    </table>
    </td>
    </tr>
  <tr>
    <td colspan="2">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
<?php
	for($i=0;$i<count($toolsArray);$i+=3)
	{
		echo "<tr>";
		for($j=0;$j<3&&$j+$i<count($toolsArray);$j++)
		{
			echo "<th>".$toolsArray[($i+$j)]->tool_name."</th>";
			echo "<td><div class='sp-textbox6'>";
			echo CHtml::dropDownList('tools[]', $toolsArray[($i+$j)],
			 array($toolsArray[($i+$j)]->tool_ID=>'YES', -1*$toolsArray[($i+$j)]->tool_ID=>'NO'), array('onchange'=>'changeStatus(DOMAIN.PROFILE, STATUS.CHANGED)', 'id'=>$toolsArray[($i+$j)]->tool_name));
			echo "</div></td>";
		}
		echo "</tr>";
	}
?>
    </table></td>
    </tr>
</table>
</div><!-- End Site Details 2 -->
<div id="ms-submit2">
	<?php echo CHtml::imageButton(Yii::app()->request->baseUrl.'/images/submit5.jpg', array(
										'ajax'=>array(				
											'type'=>'POST',
											'url'=>CController::createUrl('mySites/profile'),
											'success'=>'updateProfileStatus',
											'dataType'=>'json',
										),
									)
								); ?>
</div>
</div><!-- End Sp Left -->

<?php $this->endWidget(); ?>

<div id='tank-area' style='display:none'>
	<?php
		$tank = new Tanks;
		$tank->scenario = 'update'; 
		$this->renderPartial('tank',array('tank'=>$tank)); 
	?>
</div>
</div><!-- End Ms Main contents -->
